package com.ita.iosa.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ita.iosa.po.Merchant;
import com.ita.iosa.service.AdminManager;
import com.ita.iosa.service.impl.AdminManagerImpl;

/**
 * Servlet implementation class BlackListServlet
 */
public class BlackListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private AdminManager adminManager = new AdminManagerImpl();  
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BlackListServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) {
		List<Merchant> blackMerchants = new ArrayList<Merchant>();
		blackMerchants = adminManager.showBlackMerchants();
		
		if (!blackMerchants.isEmpty()) {
			request.setAttribute("blackMerchants", blackMerchants);
		}
		else {
			request.setAttribute("NONE3", "No blcak merhcant");
		}
		try {
			request.getRequestDispatcher("/iosa/jsp/admin/black.jsp").forward(request, response);
		} catch (ServletException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
